<template>

	<div>
		<el-form ref="form" :model="form" label-width="80px">
			<el-form-item label="姓名">
				<el-input v-model="form.name"></el-input>
			</el-form-item>
			<el-form-item label="密码">
				<el-input v-model="form.password"></el-input>
			</el-form-item>
			<el-form-item label="确认密码">
				<el-input v-model="form.rpassword"></el-input>
			</el-form-item>
			<el-form-item label="手机号">
				<el-input v-model="form.telphone"></el-input>
			</el-form-item>

			<el-form-item>


				<el-button type="primary" @click="reg()">免费注册</el-button>
			</el-form-item>
		</el-form>
	</div>
</template>

<script>
	import axios from "axios"

	export default {
		data() {
			return {
				form: {
					name: '',
					password: '',
					rpassword: '',
					telphone: ''
				}
			}
		},
		methods: {

			reg() {

				if (this.form.password != this.form.rpassword) {
					this.$message.error("两次密码不一致");
					return;
				}

				axios.post('http://localhost:8172/api/user-store/reg', this.form).then(res => {
					console.log(res)
					if(res.data.code==1){
						this.$message({
							message: '恭喜你，注册成功',
							type: 'success'
						});
						
						this.$router.push({
							path:"/login"
						})
					}else{
						this.$message.error("注册失败");
					}
				})
			}
		}
	}
</script>

<style>
</style>